﻿<? 
include '../bd.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>LABA 5</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../js/jq.js"></script>  
<style type="text/css"> 
    #region {
        padding: 3px 17px;
        border: 1px solid red;
        width: 400px;
        display: none;
        
    }
</style>
<script type="text/javascript">
    function echo_town(name){
        $("#region").slideUp("fast");
        $.ajax({  
            url: "echo_town.php",
            data: "town="+name,
            cache: false,  
            error: function(html){  
            $("#region").html("Error");  
                },
            success: (function(html){  
            $("#region").html(html);  
            $("#region").slideDown("slow");
                })
            });
        
    };
       
    
    
    
    function echo_region(name){
        $("#region").slideUp("fast");
        $.ajax({  
            url: "echo_town.php",
            data: "town="+name,
            cache: false,  
            error: function(html){  
            $("#region").html("Error");  
                },
            success: (function(html){  
            $("#region").html(html);  
            $("#region").slideDown("slow");
                })
            });
        
    };
    

</script>
</head>

<body>
    <table>
        <tr valign="top">
            <td>
                <form>
                    <select name="country" onchange="echo_town(this.value);">
                       <? 
                            $res_rown = mysql_query("SELECT * FROM town ORDER BY street",$db);
                            $myrow_town = mysql_fetch_array($res_rown);
                            do
                            {			
                            printf("<option>%s</option>",$myrow_town["street"] );
                    }
                    while($myrow_town = mysql_fetch_array($res_rown));
                       ?>
                    </select>
                </form>
            </td>
            <td><div id="region"></div></td>
        </tr>
    </table>
</body>
</html>